#include<iostream>
using namespace std;
class SeqList {
private:
	int* list;
	int maxsize;
	int size;
public:
	SeqList() {
		int size = 0;
		maxsize = 100;
		list = new int[maxsize];
	}
	void Init(int n, int* a) {
		for (int i = 0; i < n; i++) {
			list[i] = a[i];
			size++;
		}
	}
	void move(int i, int n) {
		int* a = new int[size];
		int m;
		if(i==0){
			n = size - n;
		}
		for (int j = 0; j < size; j++) {
			m = (j + n) % (size);
			a[m] = list[j];
		}
		for (int j = 0; j < size; j++) {
			list[j] = a[j];
		}
	}
	void print() {
		for (int i = 0; i < size; i++) {
			cout << list[i] << ' ';
		}
		cout << endl;
	}
	~SeqList() {
		delete[] list;
	}
};
int main()
{
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	SeqList sl;
	sl.Init(n, a);
	sl.print();
	int i;
	cin >> i >> n;
	sl.move(i, n);
	sl.print();
	cin >> i >> n;
	sl.move(i, n);
	sl.print();

}